<template>
	<view class="main">
		<image class="login-imag" src="../../static/images/login_02.png" mode=""></image>
		
		
		<view class="daohangkuang">
			<view class="shurukuang">
				<view class="shoujihao">
					<input class="input-sjh" type="text" placeholder="请输入密码" v-model='pass'>
				</view>
				<view class="yamzma">
					<input class="input-sjh" type="text" placeholder="再次输入密码" v-model='againpass'>
				</view>
			</view>
		</view>
		
		
		<view class="xieyishu">
			<label @tap="Agreement">
				<radio value="false" :checked="User"/>
				<text class="woyi">
					我已阅读并同意
					<span class="yh">《用户使用协议》</span>
					和
					<span class="yh">《隐私协议》</span>
				</text>
			</label>
		</view>
		
		<view class="xiayibu" @click='wordsubmit'>确认提交</view>
		
	</view>
</template>

<script>
	import Index from '@/apis/index.js'
	export default {
		data() {
			return {
				// 单选框状态
				User:false,
				// 密码
				pass:'',
				// 确认密码
				againpass:'',
				//手机号
				mobile:''
			}
		},
		onLoad: function (option) { //option为object类型，会序列化上个页面传递的参数
				// console.log(option.mobile); //打印出上个页面传递的参数。
				this.mobile = option.mobile
				
		},
		methods: {
			// 单选框的状态
			Agreement(){
				this.User=!this.User
			},
			// 确认提交
			async wordsubmit(){
				if(this.pass==''){
					this.$message.error('密码不能为空')
					return
				}
				if(this.againpass==''){
					this.$message.error('再次输入密码不能为空')
					return
				}
				if(this.pass!=this.againpass){
					this.$message.error('两次密码不一致')
					return
				}
				if(!this.User){
					this.$message.error('请勾选用户使用协议')
					return
				}
				let res = await Index.memberreg({mobile:this.mobile,pass:this.pass})
				// console.log(res)
				if(res.errCode==10000){
					uni.redirectTo({
						url:'/pages/HousePage/HousePage'
					})
					this.$message.none('注册成功')
				}else{
					this.$message.error(res.msg)
				}
			},
		}
	}
</script>

<style>
@import url('../../static/css/registerr/registerr.css');
</style>
